const Game_Object=[]
export class AcGamePbject{
    constructor(){
        Game_Object.push(this);
        this.timedelta = 0;
        this.isstart = false;
    }
    start() {  // 只执行一次
    }

    update() {  // 每一帧执行一次，除了第一帧之外

    }

    on_destroy() {  // 删除之前执行

    }


    destroy(){
        this.on_destroy()

        for(let i in Game_Object){
            const obj = Game_Object[i];
            if(obj == this){
                Game_Object.splice(i);
                break;
            }
        }
    }
}
//上一次执行的时刻
let last_timestamp;
const step = timestamp =>{
    for(let obj of Game_Object){
        if(obj.isstart == false){
            obj.isstart = true;
            obj.start();
        }else{
            obj.timedelta = timestamp - last_timestamp;
            obj.update(); 
        }
    }
    last_timestamp = timestamp;
    requestAnimationFrame(step)
}
requestAnimationFrame(step)